/*
 * This calendar application is brought to you
 * by Group 3 of User Interface Programming II, vt11.
 *
 * Group Members:
 * Pooya | Flora | Monica | Can
 */
package vical.utility;

import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;

/**
 * This class contains common functions that are used in this calendar application.
 *
 * @author Pooya
 */
public final class Functions {

    /**
     * Converts month's number to month's name
     * @param monthNumber, should be 0~11, stands for Jan. ~ Dec.
     * @return
     */
    public static String getMonthName(int monthNumber) {
        String[] monthName = {"January", "February",
            "March", "April", "May", "June", "July",
            "August", "September", "October", "November",
            "December"};
        return monthName[monthNumber];
    }

    public static ImageIcon scale(Component container, Image src, double scale) {
        int w = (int)(scale*src.getHeight(null));
        int h = (int)(scale*src.getHeight(null));
        int type = BufferedImage.TYPE_4BYTE_ABGR_PRE;
        BufferedImage dst = new BufferedImage(w, h, type);
        Graphics2D g2 = dst.createGraphics();
        g2.drawImage(src, 0, 0, w, h, container);
        g2.dispose();
        return new ImageIcon(dst);
    }

}
